<?php


class mdl_auth extends CI_Model{

		
	function __construct(){
		//parent::CI_Model();
		parent::__construct();
		//$this->obj =& get_instance();
          			 		
	}
	
	function user_exist($username, $password){
		$this->db->select('*');
		$this->db->from('users');
		$this->db->where('username',$username);					
		$this->db->where('password',md5($username.$password));					
		return $this->db->get();
	}
	
	function get_countitem($username, $password){
		$this->db->flush_cache();
		$this->db->from('users');	
		$this->db->where('password',md5($username.$password));		
		return  $this->db->count_all_results();
	}
	
	function getGroup($data){	
		$query = $this->db->get_where('USER_GROUP',$data);			
        //echo $this->db->last_query(); 
		//ECHO"XXXXXXXXXXXXXXX";
		//echo $query->num_rows(); 
		//ECHO  $query->result_array[0]["USER_GROUP_NAME"];
		//var_dump( $query->result_array);exit;		
		return $query->result_array[0]["USER_GROUP_NAME"];		
	}
	
	function update($values, $where){
   		$sql = $this->db->_update($this->table, $values, $where, $orderby = array(), $limit = FALSE);   		   	
   		//echo $sql; exit;
   		$this->db->query($sql);
   }
   

   
   function getDataUser($userid){
   	$query = $this->db->query("select * from users where user_id='".$userid."'");
		  
		  foreach ($query->result() as $row)
		{
		   $data['email']= $row->EMAIL;
		   $data['name']= $row->NAME;
		   $data['username']= $row->USERNAME;
		   /*$data['level']= $row->LEVEL;
		   $data['kode_upt']= $row->KODE_UPT; */
		}
   	
   	return $data;
   }
   
   
   
}
?>
